# 作者: 陈其志 
# 2025年02月18日22时30分52秒 
# 2716847110@qq.com

# 1、列表的查询：取值和取索引
def list_search_content(name_list_1, content):
    """
    按照内容查找索引地址：取索引
    :param name_list_1:
    :param content:
    :return:
    """
    print(name_list_1.index(content))
    return name_list_1.index(content)


def list_search_index(name_list_2, index):
    """
    按照索引查找内容：取值
    :param name_list_2:
    :param index:
    :return:
    """
    print(name_list_2[index])
    return name_list_2[index]


# 2、列表的修改
def list_change(list_1, index, value):
    """
    按照索引修改值
    :param list_1:
    :param index:
    :param value:
    :return:
    """
    list_1[index] = value
    print(list_1)
    return list_1


# 3、增加
def list_add(list_2, value):
    """
    在列表末尾添加
    :param list_2:
    :param value:
    :return:
    """
    list_2.append(value)
    print(list_2)
    print(id(list_2))


# 4、插入
def list_insert(list_3, index, value):
    """
    在指定索引位置插入value
    :param list_3:
    :param index:
    :param value:
    :return:
    """
    list_3.insert(index, value)  # 大于索引会插入到末尾
    print(list_3)


# 5、继承extend
def list_extend(list_4, list_5):
    """

    :param list_4:
    :param list_5:
    :return:
    """
    print(id(list_4))
    print(id(list_5))
    list_4.extend(list_5)
    print(list_4)
    print(id(list_4))


# 6、删除
def list_del_index(list_1, index):
    """
    按照索引删除
    :param list_1:
    :param index:
    :return:
    """
    del list_1[index]
    print(list_1)


def list_del_value(list_1, value):
    """
    按照内容删除
    :param list_1:
    :param value:
    :return:
    """
    list_1.remove(value)
    print(list_1)


if __name__ == '__main__':
    name_list = ['cqz', 'cys', 'cyx']
    # list_search_content(name_list, 'cyx')
    # list_search_index(name_list, 1)
    # list_change(name_list, 0, '陈其志')
    # print(id(name_list))
    # list_add(name_list, 'zjz')
    # print(id(name_list))
    # list_insert(name_list, 0, 'zjz')
    # list_insert(name_list, 5, '王小美')
    # list_extend([1, 2, 3], [4, 5, 6])
    # list_del_index(name_list, 1)
    list_del_value(name_list, 'cqz')